package carmensd.vista

import applicationModel.EditarLugaresAppModel
import carmensd.vista.expedienteYvillanos.AsistenteDeContenidos
import modelo.Lugar
import org.uqbar.arena.aop.windows.TransactionalDialog
import org.uqbar.arena.layout.HorizontalLayout
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.Selector
import org.uqbar.arena.windows.WindowOwner

class EditarLugaresWindow extends TransactionalDialog<EditarLugaresAppModel>{
	
	new(WindowOwner owner, EditarLugaresAppModel model) {
		super(owner, model)
	}
	
	override protected createFormPanel(Panel panel) {
		this.title = "editar lugares"
		panel.setLayout(new VerticalLayout())
		
		AsistenteDeContenidos.crearLista(panel,"lugarElegidoAEliminar",typeof(Lugar),"nombreLugar")
			.bindItemsToProperty("paisElegido.lugaresElegidos")
		
		
		new Selector(panel) =>[
			bindItemsToProperty("paisElegido.lugaresDeInteres")
			bindValueToProperty("lugarElegido")
		]
		
		this.colocarBotones(panel)
		
	}
	
	def colocarBotones(Panel panel) {
		var Panel panelChico = new Panel(panel)
		panelChico.setLayout(new HorizontalLayout())
		
		new Button(panel) =>[
			caption = "Agregar Lugar"
			onClick[| this.modelObject.agregarLugar()]
		]
		new Button(panel) =>[
			caption = "Eliminar Lugar"
			onClick[| this.modelObject.eliminarLugar()]
		]
		new Button(panel) =>[
			caption = "Aceptar"
			onClick[| this.close]
		]
	}
	
}